function do_login(obj, url){
	$.ajax({
        type: "post",
        url: url,
        data: $(obj).serialize(),
        dataType: "json", 
        success: function (msg) {
            if(msg.code == 200){
                layer.msg(msg.msg, {icon:1, time:800}, function(){
                    location.href = msg.url;
                });
            }else if(msg.code == -1){
				layer.msg(msg.msg, {icon:2,time: 1500});
				$("#codeimg").attr('src',$("#codeimg").attr('src') + '?' + Math.random());
			}else{
                layer.msg(msg.msg, {icon:2});
                $("#codeimg").attr('src',$("#codeimg").attr('src') + '?' + Math.random());
            }
        }
    });
    return false;
}
// 系统post总ajax提交
function qh_post(data,url) {
	$.ajax({
		type: 'POST',
		url: url, 
		data: $(data).serialize(),
		dataType: "json", 
		error: function(error){
		    layer.msg(error.responseJSON.message, {icon:2});   
	    },
		success: function (msg) {
			if(msg.code == 200){
			 layer.msg(msg.msg, {icon:1,time: 2000}, function(){
				window.location.reload();
			});
			}else{
				layer.msg(msg.msg, {icon:2}); 
			}
		}
	   
	});
	
	return false;
}
// 提示类ajax
function confirm(data,url,title){
	layer.confirm(''+title+'',function(index){
		$.ajax({
			type: 'POST',
			url: url, 
			data: $(data).serialize(),
			dataType: "json",
			error: function(error){
    		    layer.msg(error.responseJSON.message, {icon:2});   
    	    },
			success: function (msg) {
				if(msg.code == 200){
					layer.msg(msg.msg, {icon:1,time: 2000}, function(){
						window.location.reload();
					});
				}else{
					layer.msg(msg.msg, {icon:2}); 
				}
			}
		})
	});
	return false;
}
function attribute_operation(s, url) {
    var ids = $("input[name='fx[]']:checked");
    if (ids.length < 1) {
        layer.msg('请选择要操作的内容！', {icon:2});
        return false;
    }

    var str = '';
    $.each(ids,
    function() {
        if (this.checked) {
            str += $(this).val() + ',';
        }
    });
    str = str.substr(0, str.length - 1);
    layer.open({
        type: 2,
        title: s,
        shadeClose: true,
        shade: 0.2,
        area: ['500px', '350px'],
        content: url,
        success: function(layero, index) {
            var body = layer.getChildFrame('body', index);
            body.find('#ids').val(str);
        }
    })

}
//关闭弹出层
function qh_close(){
	var index = parent.layer.getFrameIndex(window.name);
	parent.layer.close(index);
}
// 删除选中
var fx = document.getElementsByName("fx[]");
function cz(obj) {
    for (var i = 0; i < fx.length; i++) {
        fx[i].checked = obj.checked;
    }
}
function post_password(obj,url){
    return qh_post(obj,url)
}
function post_add(obj,url){
    return qh_post(obj,url)
}
function post_del(obj,url,title){
    return confirm(obj,url,title)
}
function clear_del(obj,url,title){
    return confirm(obj,url,title)
}
function refresh(){
    window.location.reload();
}
//打开页面
function qh_open(title,url,w,h){
	if (w == undefined || w == null) {
		w = ($(window).width() * 0.8);
	}
	if (h == undefined || h == null) {
		h = ($(window).height() * 0.8);
	}
    	// 在此处输入 layer 的任意代码
    layer.open({
      type: 2, // page 层类型
      area: [w+'px', h +'px'],
      title: title,
      shade: 0.6, // 遮罩透明度
      shadeClose: true, // 点击遮罩区域，关闭弹层
      maxmin: true, // 允许全屏最小化
      anim: 0, // 0-6 的动画形式，-1 不开启
      content: url
    });
} 
//大窗口打开页面
function open_full(title,url){
	var index = layer.open({
		type: 2,
		title: title,
		content: url
	});
	layer.full(index);
}

//全局WIN变量
_win.bd = $(".body");

var _wid = $(window).width()
  , _hei = $(window).height();
/**模态框居中 */
_win.bd.on("show.bs.modal loaded.bs.modal", ".modal:not(.flex)", function() {
    var t = $(this)
      , e = t.find(".modal-dialog");
    t.css("display", "block"),
    e.css({
        "margin-top": Math.max(0, (_hei - e.height()) / 2)
    })
}),
$.fn.minitouch = function(t) {
    t = $.extend({
        direction: "bottom",
        selector: "",
        start_selector: "",
        depreciation: 50,
        stop: !1,
        onStart: !1,
        onIng: !1,
        onEnd: !1,
        inEnd: !1
    }, t);
    var e = $(this)
      , a = !1
      , i = t.depreciation
      , n = 0
      , o = 0
      , r = 0
      , s = 0
      , l = 0
      , d = 0
      , c = 0
      , u = !1
      , h = function(t, e, a, i, n) {
        var o, r, s;
        i && (e += "px",
        a += "px",
        o = "translate3D(" + e + "," + a + " , 0)",
        r = {},
        s = f(),
        r[s + "transform"] = o,
        r[s + "transition"] = s + "transform 0s linear",
        r.cursor = n,
        "null" == i && (r[s + "transform"] = "",
        r[s + "transition"] = ""),
        t.css(r))
    }
      , f = function() {
        var t = document.body || document.documentElement;
        return t = t.style,
        "" == t.WebkitTransition ? "-webkit-" : "" == t.MozTransition ? "-moz-" : "" == t.OTransition ? "-o-" : "" == t.transition ? "" : void 0
    }
      , p = t.start_selector || t.selector;
    e.on("touchstart pointerdown MSPointerDown", p, function(t) {
        n = o = r = s = l = d = c = 0,
        n = t.originalEvent.pageX || t.originalEvent.touches[0].pageX,
        o = t.originalEvent.pageY || t.originalEvent.touches[0].pageY,
        u = !0,
        $(t.target).parentsUntil(p, ".swiper-container,.scroll-x").length && (u = !1)
    }).on("touchmove pointermove MSPointerMove", p, function(i) {
        var f = t.start_selector ? t.selector ? e.find(t.selector) : e.find(t.start_selector) : $(this);
        $.isFunction(t.stop) && (a = t.stop(e, f, n, o)),
        u && !a && (r = i.originalEvent.pageX || i.originalEvent.touches[0].pageX,
        s = i.originalEvent.pageY || i.originalEvent.touches[0].pageY,
        d = r - n,
        c = s - o,
        l = 180 * Math.atan2(c, d) / Math.PI,
        "right" == t.direction && (c = 0,
        d = l > -40 && l < 40 && d > 0 ? d : 0),
        "left" == t.direction && (c = 0,
        d = (l > 150 || l < -150) && 0 > d ? d : 0),
        "top" == t.direction && (d = 0,
        c = l > -130 && l < -50 && 0 > c ? c : 0),
        "bottom" == t.direction && (d = 0,
        c = l > 50 && l < 130 && c > 0 ? c : 0),
        0 === d && 0 === c || (i.preventDefault ? i.preventDefault() : i.returnValue = !1,
        h(f, d, c, u, "grab"),
        $.isFunction(t.onIng) && t.onIng(e, f, d, c)))
    }).on("touchend touchcancel pointerup MSPointerUp", p, function(f) {
        var p = t.start_selector ? t.selector ? e.find(t.selector) : e.find(t.start_selector) : $(this);
        u && !a && (h(p, 0, 0, "null", ""),
        $.isFunction(t.inEnd) && t.inEnd(e, p, d, c),
        (Math.abs(d) > i || Math.abs(c) > i) && $.isFunction(t.onEnd) && t.onEnd(e, p, d, c),
        n = o = r = s = l = d = c = 0,
        u = !1)
    })
}
_win.bd.on("click", "#post-tab-toggle", function(t) {
    var e = $(this)
      , a = e.attr("tab-id");
    if (!e.parent().hasClass("picked")) {
        var i = e.parent().addClass("picked").siblings().removeClass("picked").parent().next().find('[tab-id="' + a + '"]');
        i.siblings().removeClass("in"),
        setTimeout(function() {
            i.addClass("picked").siblings().removeClass("picked")
        }, 150),
        setTimeout(function() {
            i.addClass("in")
        }, 160)
    }
});
//每次都刷新的模态框
_win.bd.on("click", '[data-toggle="RefreshModal"]', function() {
    var t = $(this)
      , e = t.attr("data-class") || ""
      , b = t.attr("data-modal") || ""
      , a = t.attr("data-remote")
      , i = t.attr("data-height") || 300
      , n = t.attr("mobile-bottom") && _wid < 769 ? " bottom" : ""
      , o = "modal flex jc fade" + n
      , r = "refresh_modal"
      , s = t.attr("new");
    r += s ? parseInt((Math.random() + 1) * Math.pow(10, 4)) : "";
    var l = "#" + r;
    e += " modal-dialog";
    var d = '<div class="' + o + '" id="' + r + '" tabindex="-1" role="dialog" aria-hidden="false">    <div class="' + e + '"  role="document">    <div class="' + b + ' modal-content">    </div>    </div>    </div>    </div>'
      , c = '<div class="modal-body" style="display:none;"></div><div class="flex jc loading-mask absolute main-bg radius8"><div class="em2x opacity5"><svg viewBox="25 25 50 50" class="circular"><circle cx="50" cy="50" r="20" fill="none" class="path"></circle></svg></div></div>'
      , u = $(l);
    u.length ? (u.hasClass("in") && (o += " in"),
    u.removeClass().addClass(o),
    u.find(".modal-dialog").removeClass().addClass(e),
    u.find(".loading-mask").fadeIn(200),
    u.find(".modal-content").css({
        overflow: "hidden"
    }).animate({
        height: i
    })) : (_win.bd.append(d),
    u = $(l),
    s && u.on("hidden.bs.modal", function() {
        $(this).remove()
    }),
    u.find(".modal-content").html(c).css({
        height: i,
        overflow: "hidden"
    }),
    _wid < 769 && u.minitouch({
        direction: "bottom",
        selector: ".modal-dialog",
        start_selector: ".modal-colorful-header,.touch-close,.touch",
        onEnd: function(t) {
            u.modal("hide")
        },
        stop: function(t) {
            return !u.hasClass("bottom")
        }
    })),
    u.find(".touch-close").remove();
    var h = '<div class="touch-close"></div>';
    return n && !t.attr("no-touch") && u.find(".modal-dialog").append(h),
    u.modal("show"),
    $.get(a,null, function(t, e) {
        u.find(".modal-body").html(t).slideDown(200, function() {
            u.trigger("loaded.bs.modal").find(".loading-mask").fadeOut(200);
            var t = $(this).outerHeight();
            u.find(".modal-content").animate({
                height: t
            }, 200, "swing", function() {
                u.find(".modal-content").css({
                    height: "",
                    overflow: "",
                    transition: ""
                })
            })
      }),
      
    !1})
   
});
$(function() {
	//禁用“确认重新提交表单”
	window.history.replaceState(null, null, window.location.href);
})